home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Text / print / HPDJ870Src.lha / transfer.c < prev   
C/C++ Source or Header  |  2004-05-15  |  4KB  |  105 lines

  1. /*
  2.  * Transfer routine for HP_Deskjet_820C
  3.  */
  4.  
  5. #include "global.h"
  6.  
  7. #define NUMCOLORCMD 7
  8.  
  9. extern struct PrinterData *PD;
  10. extern struct PrinterExtendedData *PED;
  11.  
  12. void Transfer(struct PrtInfo *PInfo, ULONG y, UBYTE *colors[], UWORD RowSize, UWORD NumColorBuf)
  13.         static UBYTE bit_table[] = {128, 64, 32, 16, 8, 4, 2, 1};
  14.         UBYTE *dmatrix, Black, dvalue, threshold;
  15.         union colorEntry *ColorInt;
  16.         UWORD x, width, sx, *sxptr;
  17.         UBYTE Yellow, Magenta, Cyan, *bptr, *yptr, *mptr, *cptr;
  18.  
  19.         /* pre-compute */
  20.         /* printer non-specific, MUST DO FOR EVERY PRINTER */
  21.         x = PInfo->pi_xpos; /* get starting x position */
  22.         ColorInt = PInfo->pi_ColorInt; /* get ptr to color intensities */
  23.         sxptr = PInfo->pi_ScaleX;
  24.         width = PInfo->pi_width; /* get # of source pixels */
  25.         bptr = colors[0]; /* Assign color pointers */
  26.         cptr = colors[1];
  27.         mptr = colors[2];
  28.         yptr = colors[3];
  29.  
  30.         /* pre-compute threshold; are we thresholding? */
  31.  
  32.         if (threshold = PInfo->pi_threshold) { /* thresholding */
  33.                 dvalue = threshold ^ 15; /* yes, so pre-compute dither value */
  34.                 do { /* for all source pixels */
  35.                         /* pre-compute intensity value for Black */
  36.                         Black = ColorInt->colorByte[PCMBLACK];
  37.                         ColorInt++; /* bump ptr for next time */
  38.  
  39.                         sx = *sxptr++;
  40.  
  41.                         /* dither and render pixel */
  42.                         do { /* use this pixel 'sx' times */
  43.                                 /* if we should render Black */
  44.                                 if (Black > dvalue) {
  45.                                         /* set bit */
  46.                                         *(bptr + (x >> 3)) |= bit_table[x & 7];
  47.                                 }
  48.                                 ++x; /* done 1 more printer pixel */
  49.                         } while (--sx);
  50.                 } while (--width);
  51.         }
  52.         else { /* not thresholding, pre-compute ptr to dither matrix */
  53.              dmatrix = PInfo->pi_dmatrix + ((y & 3) << 2);
  54.              if (PD->pd_Preferences.PrintShade == SHADE_GREYSCALE)
  55.              {
  56.                 do { /* for all source pixels */
  57.                         /* pre-compute intensity value for Black */
  58.                         Black = ColorInt->colorByte[PCMBLACK];
  59.                         ColorInt++; /* bump ptr for next time */
  60.  
  61.                         sx = *sxptr++;
  62.  
  63.                         /* dither and render pixel */
  64.                         do { /* use this pixel 'sx' times */
  65.                                 /* if we should render Black */
  66.                                 if (Black > dmatrix[x & 3]) {
  67.                                         /* set bit */
  68.                                         *(bptr + (x >> 3)) |= bit_table[x & 7];
  69.                                 }
  70.                                 ++x; /* done 1 more printer pixel */
  71.                         } while (--sx);
  72.                 } while (--width);
  73.              }
  74.              else
  75.              { /* color */
  76.                do {
  77.                     Black = ColorInt->colorByte[PCMBLACK];
  78.                     Yellow = ColorInt->colorByte[PCMYELLOW];
  79.                     Magenta = ColorInt->colorByte[PCMMAGENTA];
  80.                     Cyan = ColorInt->colorByte[PCMCYAN];
  81.                     ColorInt++;
  82.  
  83.                     sx = *sxptr++;
  84.  
  85.                     do {
  86.                          dvalue = dmatrix[x & 3];
  87.                          if (Black > dvalue)
  88.                               *(bptr + (x >> 3)) |= bit_table[x & 7];
  89.                          else
  90.                          {
  91.                               if (Yellow > dvalue)
  92.                                    *(yptr + (x >> 3)) |= bit_table[x & 7];
  93.                               if (Magenta > dvalue)
  94.                                    *(mptr + (x >> 3)) |= bit_table[x & 7];
  95.                                if (Cyan > dvalue)
  96.                                   *(cptr + (x >> 3)) |= bit_table[x & 7];
  97.                          }
  98.                         ++x;
  99.                     } while (--sx);
  100.                } while (--width);
  101.              } /* endif */
  102.          } /* endif */
  103. } /* end main */
  104.